asyncapi: '3.0.0'
info:
  title: Parties Connector
  version: '1'
  description: |
    AsyncAPI definition for party-related operations in the banking system.
    This API enables the creation and management of individual and organizational parties.

    :::warning
    Please note that all the *Commands* and *Events* are wrapped into *Envelope* before being dispatched via Channels.
    :::
    
    Specific properties that are present in the metadata section of the envelope varied per message.
    The list of required metadata properties is provided in the header's documentation of the corresponding message.
    
    See this <Link href="/docs/index.html">page</Link> for the more details on the *Envelope* structure and other cross-cutting concerns.

operations:
  # commands
  CreateIndividualParty:
    action: receive
    channel:
      $ref: '#/channels/parties.command.create-individual-party'
    messages:
      - $ref: '#/channels/parties.command.create-individual-party/messages/CreateIndividualPartyCommand'

  CreateIndividualLead:
    action: receive
    channel:
      $ref: '#/channels/parties.command.create-individual-lead'
    messages:
      - $ref: '#/channels/parties.command.create-individual-lead/messages/CreateIndividualLeadCommand'

  CreateOrganisationParty:
    action: receive
    channel:
      $ref: '#/channels/parties.command.create-organisation-party'
    messages:
      - $ref: '#/channels/parties.command.create-organisation-party/messages/CreateOrganisationPartyCommand'

  AssignOrganisationMember:
    action: receive
    channel:
      $ref: '#/channels/parties.command.assign-organisation-member'
    messages:
      - $ref: '#/channels/parties.command.assign-organisation-member/messages/AssignOrganisationMemberCommand'

  # events
  IndividualPartyCreated:
    action: send
    channel:
      $ref: '#/channels/parties.event.individual-party-created'
    messages:
      - $ref: '#/channels/parties.event.individual-party-created/messages/IndividualPartyCreatedEvent'

  IndividualPartyCreationFailed:
    action: send
    channel:
      $ref: '#/channels/parties.event.individual-party-creation-failed'
    messages:
      - $ref: '#/channels/parties.event.individual-party-creation-failed/messages/IndividualPartyCreationFailedEvent'

  IndividualLeadCreated:
    action: send
    channel:
      $ref: '#/channels/parties.event.individual-lead-created'
    messages:
      - $ref: '#/channels/parties.event.individual-lead-created/messages/IndividualLeadCreatedEvent'

  IndividualLeadCreationFailed:
    action: send
    channel:
      $ref: '#/channels/parties.event.individual-lead-creation-failed'
    messages:
      - $ref: '#/channels/parties.event.individual-lead-creation-failed/messages/IndividualLeadCreationFailedEvent'

  IndividualPersonalDetailsUpdated:
    action: send
    channel:
      $ref: '#/channels/parties.event.individual-personal-details-updated'
    messages:
      - $ref: '#/channels/parties.event.individual-personal-details-updated/messages/IndividualPersonalDetailsUpdatedEvent'

  OrganisationPartyCreated:
    action: send
    channel:
      $ref: '#/channels/parties.event.organisation-party-created'
    messages:
      - $ref: '#/channels/parties.event.organisation-party-created/messages/OrganisationPartyCreatedEvent'

  OrganisationPartyCreationFailed:
    action: send
    channel:
      $ref: '#/channels/parties.event.organisation-party-creation-failed'
    messages:
      - $ref: '#/channels/parties.event.organisation-party-creation-failed/messages/OrganisationPartyCreationFailedEvent'

  OrganisationMemberAssigned:
    action: send
    channel:
      $ref: '#/channels/parties.event.organisation-member-assigned'
    messages:
      - $ref: '#/channels/parties.event.organisation-member-assigned/messages/OrganisationMemberAssignedEvent'

  OrganisationMemberAssignmentFailed:
    action: send
    channel:
      $ref: '#/channels/parties.event.organisation-member-assignment-failed'
    messages:
      - $ref: '#/channels/parties.event.organisation-member-assignment-failed/messages/OrganisationMemberAssignmentFailedEvent'

channels:
  parties.command.create-individual-party:
    address: parties.command.create-individual-party
    x-eventcatalog-role: provider
    messages:
      CreateIndividualPartyCommand:
        $ref: '#/components/messages/CreateIndividualPartyCommand'

  parties.command.create-individual-lead:
    address: parties.command.create-individual-lead
    x-eventcatalog-role: provider
    messages:
      CreateIndividualLeadCommand:
        $ref: '#/components/messages/CreateIndividualLeadCommand'

  parties.command.create-organisation-party:
    address: parties.command.create-organisation-party
    x-eventcatalog-role: provider
    messages:
      CreateOrganisationPartyCommand:
        $ref: '#/components/messages/CreateOrganisationPartyCommand'

  parties.command.assign-organisation-member:
    address: parties.command.assign-organisation-member
    x-eventcatalog-role: provider
    messages:
      AssignOrganisationMemberCommand:
        $ref: '#/components/messages/AssignOrganisationMemberCommand'

  parties.event.individual-party-created:
    address: parties.event.individual-party-created
    x-eventcatalog-role: provider
    messages:
      IndividualPartyCreatedEvent:
        $ref: '#/components/messages/IndividualPartyCreatedEvent'

  parties.event.individual-party-creation-failed:
    address: parties.event.individual-party-creation-failed
    x-eventcatalog-role: provider
    messages:
      IndividualPartyCreationFailedEvent:
        $ref: '#/components/messages/IndividualPartyCreationFailedEvent'

  parties.event.individual-lead-created:
    address: parties.event.individual-lead-created
    x-eventcatalog-role: provider
    messages:
      IndividualLeadCreatedEvent:
        $ref: '#/components/messages/IndividualLeadCreatedEvent'

  parties.event.individual-lead-creation-failed:
    address: parties.event.individual-lead-creation-failed
    x-eventcatalog-role: provider
    messages:
      IndividualLeadCreationFailedEvent:
        $ref: '#/components/messages/IndividualLeadCreationFailedEvent'

  parties.event.organisation-party-created:
    address: parties.event.organisation-party-created
    x-eventcatalog-role: provider
    messages:
      OrganisationPartyCreatedEvent:
        $ref: '#/components/messages/OrganisationPartyCreatedEvent'
  
  parties.event.organisation-party-creation-failed:
    address: parties.event.organisation-party-creation-failed
    x-eventcatalog-role: provider
    messages:
      OrganisationPartyCreationFailedEvent:
        $ref: '#/components/messages/OrganisationPartyCreationFailedEvent'

  parties.event.individual-personal-details-updated:
    address: parties.event.individual-personal-details-updated
    x-eventcatalog-role: provider
    messages:
      IndividualPersonalDetailsUpdatedEvent:
        $ref: '#/components/messages/IndividualPersonalDetailsUpdatedEvent'

  parties.event.organisation-member-assigned:
    address: parties.event.organisation-member-assigned
    x-eventcatalog-role: provider
    messages:
      OrganisationMemberAssignedEvent:
        $ref: '#/components/messages/OrganisationMemberAssignedEvent'

  parties.event.organisation-member-assignment-failed:
    address: parties.event.organisation-member-assignment-failed
    x-eventcatalog-role: provider
    messages:
      OrganisationMemberAssignmentFailedEvent:
        $ref: '#/components/messages/OrganisationMemberAssignmentFailedEvent'

components:
  messages:
    # Commands
    CreateIndividualPartyCommand:
      name: CreateIndividualParty
      title: Create Individual Party Command
      summary: Command to create a new individual party
      description: Instructs the system to create a new individual party with personal details
      x-eventcatalog-message-type: command
      payload:
        $ref: '#/components/schemas/CreateIndividualParty'

    CreateIndividualLeadCommand:
      name: CreateIndividualLead
      title: Create Individual Lead Command
      summary: Command to create a new individual lead
      description: Instructs the system to create a new individual lead with personal details and additional custom information
      x-eventcatalog-message-type: command
      payload:
        $ref: '#/components/schemas/CreateIndividualLead'

    CreateOrganisationPartyCommand:
      name: CreateOrganisationParty
      title: Create Organisation Party Command
      x-eventcatalog-message-type: command
      summary: Command to create a new organisation party
      description: Instructs the system to create a new organisation party with company details
      payload:
        $ref: '#/components/schemas/CreateOrganisationParty'

    AssignOrganisationMemberCommand:
      name: AssignOrganisationMember
      title: Assign Organisation Member Command
      summary: Command to assign a member to an organisation
      description: Instructs the system to assign a party as a member of an organisation
      x-eventcatalog-message-type: command
      payload:
        $ref: '#/components/schemas/AssignOrganisationMember'

    # Events
    IndividualPartyCreatedEvent:
      name: IndividualPartyCreated
      title: Individual Party Created Event
      summary: Event indicating an individual party has been created
      description: Published when a new individual party has been successfully created in the system
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/IndividualPartyCreated'
    
    IndividualPartyCreationFailedEvent:
      name: IndividualPartyCreationFailed
      title: Individual Party Creation Failed Event
      summary: Event indicating an individual party creation has failed
      description: Published when an attempt to create an individual party has failed, with failure details
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/IndividualPartyCreationFailed'

    IndividualLeadCreatedEvent:
      name: IndividualLeadCreated
      title: Individual Lead Created Event
      summary: Event indicating an individual lead has been created
      description: Published when a new individual lead has been successfully created in the system
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/IndividualLeadCreated'

    IndividualLeadCreationFailedEvent:
      name: IndividualLeadCreationFailed
      title: Individual Lead Creation Failed Event
      summary: Event indicating an individual lead creation has failed
      description: Published when an attempt to create an individual lead has failed, with failure details
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/IndividualLeadCreationFailed'

    OrganisationPartyCreatedEvent:
      name: OrganisationPartyCreated
      title: Organisation Party Created Event
      summary: Event indicating an organisation party has been created
      description: Published when a new organisation party has been successfully created in the system
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/OrganisationPartyCreated'
    
    OrganisationPartyCreationFailedEvent:
      name: OrganisationPartyCreationFailed
      title: Organisation Party Creation Failed Event
      summary: Event indicating an organisation party creation has failed
      description: Published when an attempt to create an organisation party has failed, with failure details
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/OrganisationPartyCreationFailed'

    IndividualPersonalDetailsUpdatedEvent:
      name: IndividualPersonalDetailsUpdated
      title: Individual Personal Details Updated Event
      summary: Event indicating an individual party’s personal details were updated
      description: Published when the personal details (phone, email, first and last name) of an individual party are updated
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/IndividualPersonalDetailsUpdated'

    OrganisationMemberAssignedEvent:
      name: OrganisationMemberAssigned
      title: Organisation Member Assigned Event
      summary: Event indicating a member has been assigned to an organisation
      description: Published when a party has been successfully assigned as a member of an organisation
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/OrganisationMemberAssigned'

    OrganisationMemberAssignmentFailedEvent:
      name: OrganisationMemberAssignmentFailed
      title: Organisation Member Assignment Failed Event
      summary: Event indicating an organisation member assignment has failed
      description: Published when an attempt to assign a member to an organisation has failed, with failure details
      x-eventcatalog-message-type: event
      payload:
        $ref: '#/components/schemas/OrganisationMemberAssignmentFailed'

  schemas:
    # Base Types
    Message:
      type: object
      description: Base message type that all commands and events inherit from
      required:
        - id
      properties:
        id:
          type: string
          description: Unique identifier for the message, typically a UUID
          default: UUID generated string
    
    Command:
      description: Base type for all commands in the system
      allOf:
        - $ref: '#/components/schemas/Message'
    
    Event:
      description: Base type for all events in the system
      allOf:
        - $ref: '#/components/schemas/Message'
    
    # Entity Types
    Address:
      type: object
      description: Structured representation of a physical address
      properties:
        streetName:
          type: string
          nullable: true
          description: The name of the street
        buildingNumber:
          type: string
          nullable: true
          description: The building number on the street
        buildingName:
          type: string
          nullable: true
          description: The name of the building, if applicable
        floor:
          type: string
          nullable: true
          description: The floor number within the building
        postBox:
          type: string
          nullable: true
          description: Post box or mail box identifier
        suite:
          type: string
          nullable: true
          description: Suite or apartment number
        postCode:
          type: string
          nullable: true
          description: Postal or ZIP code
        townName:
          type: string
          nullable: true
          description: The name of the town or city
        townLocationName:
          type: string
          nullable: true
          description: A specific location within the town
        districtName:
          type: string
          nullable: true
          description: District, county, or regional division
        countrySubDivision:
          type: string
          nullable: true
          description: Sub-division of the country (e.g., state, province)
        country:
          type: string
          nullable: true
          description: The country, typically as a two-letter ISO country code
      example:
        streetName: "High Street"
        buildingNumber: "42"
        buildingName: "Willow House"
        floor: "3"
        postCode: "SW1A 1AA"
        townName: "London"
        countrySubDivision: "Greater London"
        country: "GB"
    
    Document:
      type: object
      description: Represents an identification document such as passport or ID card
      required:
        - setType
        - type
        - number
      properties:
        setType:
          type: string
          description: The category or set type of the document
        type:
          type: string
          description: The specific type of document within the category
        number:
          type: string
          description: The document's unique identifier or number
      examples:
        - setType: "PASSPORT"
          type: "CURRENT"
          number: "GB9876543"
        - setType: "DRIVERS_LICENSE"
          type: "FULL"
          number: "SMITH907152AB9XY"
    
    OrganisationMember:
      type: object
      description: Represents a member (person or organization) of an organization
      required:
        - partyId
      properties:
        qualifiedOriginPartyId:
          type: string
          format: uri
          description: The qualified origin system identifier of the party who is a member of the organization
    
    Status:
      type: string
      description: Represents the activity status of a party
      enum:
        - INACTIVE
        - ACTIVE
      example: "ACTIVE"
    
    TaxIdentification:
      type: object
      description: Represents tax-related identification information for a party
      required:
        - id
      properties:
        id:
          type: string
          description: Unique identifier for the tax identification record
        tin:
          type: string
          nullable: true
          description: Tax Identification Number
        country:
          type: string
          nullable: true
          description: The country to which the tax identification applies
        reasonNoTin:
          type: string
          nullable: true
          description: Reason code explaining why there is no TIN, if applicable
        reasonDescription:
          type: string
          nullable: true
          description: Textual description explaining why there is no TIN
        primary:
          type: boolean
          nullable: true
          description: Indicates whether this is the primary tax identification for the party
      example:
        id: "tax-id-12345"
        tin: "AB123456C"
        country: "GB"
        primary: true
    
    Failure:
      type: object
      description: Represents a failure condition with error code and reason
      required:
        - code
        - reason
      properties:
        code:
          type: string
          description: The error code identifying the type of failure
        reason:
          type: string
          description: Human-readable description of the failure reason
    
    # Command Schemas
    CreateIndividualParty:
      allOf:
        - $ref: '#/components/schemas/Command'
        - type: object
          description: Command to create a new individual party with personal details
          properties:
            salutation:
              type: string
              nullable: true
              description: Formal greeting prefix (e.g., Mr, Mrs, Ms, Dr)
            title:
              type: string
              nullable: true
              description: Honorary, professional, or academic title
            firstName:
              type: string
              nullable: true
              description: The individual's first name or given name
            lastName:
              type: string
              nullable: true
              description: The individual's last name or family name
            middleNames:
              type: string
              nullable: true
              description: Any middle names or initials
            dateOfBirth:
              type: string
              format: date
              nullable: true
              description: The individual's date of birth in ISO format (YYYY-MM-DD)
            phoneNumber:
              type: string
              nullable: true
              description: Contact phone number
            email:
              type: string
              nullable: true
              description: Email address
            personalId:
              type: string
              nullable: true
              description: Personal identification number or code
            preferredLanguage:
              type: string
              nullable: true
              description: The individual's preferred language for communication
            registrationAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Official registered address
            postalAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Address for postal mail if different from registration address
            taxIdentifications:
              type: array
              nullable: true
              description: List of tax identification information
              items:
                $ref: '#/components/schemas/TaxIdentification'
            documents:
              type: array
              nullable: true
              description: List of identification documents
              items:
                $ref: '#/components/schemas/Document'
            leadId:
              type: string
              nullable: true
              description: The identifier of the lead that originated this party creation
            additionalDetails:
              type: object
              additionalProperties: true
              nullable: true
              description: Additional custom details stored as key-value pairs (maps to Java Map<String, Object>)
            skipCustomerCreation:
              type: boolean
              nullable: true
              description: |
                If true, the party will be created without creating a customer record. To be used when the person created is meant to be an associate to an organisation without a need for customer operations. 
                If the property is missing or set to false, a customer is created for the party.

    CreateIndividualLead:
      allOf:
        - $ref: '#/components/schemas/Command'
        - type: object
          description: Command to create a new individual lead with personal details and additional custom information
          properties:
            salutation:
              type: string
              nullable: true
              description: Formal greeting prefix (e.g., Mr, Mrs, Ms, Dr)
            title:
              type: string
              nullable: true
              description: Honorary, professional, or academic title
            firstName:
              type: string
              nullable: true
              description: The individual's first name or given name
            lastName:
              type: string
              nullable: true
              description: The individual's last name or family name
            middleNames:
              type: string
              nullable: true
              description: Any middle names or initials
            dateOfBirth:
              type: string
              format: date
              nullable: true
              description: The individual's date of birth in ISO format (YYYY-MM-DD)
            phoneNumber:
              type: string
              nullable: true
              description: Contact phone number
            email:
              type: string
              nullable: true
              description: Email address
            personalId:
              type: string
              nullable: true
              description: Personal identification number or code
            preferredLanguage:
              type: string
              nullable: true
              description: The individual's preferred language for communication
            registrationAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Official registered address
            postalAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Address for postal mail if different from registration address
            taxIdentifications:
              type: array
              nullable: true
              description: List of tax identification information
              items:
                $ref: '#/components/schemas/TaxIdentification'
            documents:
              type: array
              nullable: true
              description: List of identification documents
              items:
                $ref: '#/components/schemas/Document'
            additionalDetails:
              type: object
              additionalProperties: true
              nullable: true
              description: Additional custom details stored as key-value pairs (maps to Java Map<String, Object>)

    CreateOrganisationParty:
      allOf:
        - $ref: '#/components/schemas/Command'
        - type: object
          description: Command to create a new organisation party with company details
          required:
            - id
          properties:
            id:
              type: string
              description: Unique identifier for the command
            country:
              type: string
              nullable: true
              description: The country where the organization is registered
            legalName:
              type: string
              nullable: true
              description: The official registered legal name of the organization
            registrationNumber:
              type: string
              nullable: true
              description: Official company registration number
            dateOfIncorporation:
              type: string
              format: date
              nullable: true
              description: Date when the organization was officially incorporated or established
            legalType:
              type: string
              nullable: true
              description: Legal type or structure of the organization (e.g., LLC, Ltd, Inc)
            tradingName:
              type: string
              nullable: true
              description: The name under which the organization conducts business, if different from legal name
            registrationAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Official registered address of the organization
            operatingAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Primary business or operational address if different from registration address
            postalAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Address for postal mail if different from other addresses
            categories:
              type: array
              nullable: true
              description: Business categories or industry classifications
              items:
                type: string
            website:
              type: string
              nullable: true
              description: Official website URL
            description:
              type: string
              nullable: true
              description: Brief description of the organization's activities
            vatNumber:
              type: string
              nullable: true
              description: Value Added Tax registration number
            members:
              type: array
              nullable: true
              description: List of parties that are members of this organization
              items:
                $ref: '#/components/schemas/OrganisationMember'

    AssignOrganisationMember:
      allOf:
        - $ref: '#/components/schemas/Command'
        - type: object
          description: Command to assign a party as a member of an organisation
          required:
            - id
            - organisationQualifiedOriginPartyId
            - memberQualifiedOriginPartyId
          properties:
            id:
              type: string
              description: Unique identifier for the command
            organisationQualifiedOriginPartyId:
              type: string
              format: uri
              description: The qualified origin system identifier of the organisation to which the member will be assigned
            memberQualifiedOriginPartyId:
              type: string
              format: uri
              description: The qualified origin system identifier of the party to be assigned as a member

    # Event Schemas
    IndividualPartyCreated:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when a new individual party has been created
          required:
            - qualifiedOriginPartyId
            - status
            - createdAt
          properties:
            qualifiedOriginPartyId:
              type: string
              format: uri
              description: The qualified origin system identifier assigned to the newly created party
            status:
              $ref: '#/components/schemas/Status'
              description: The initial activity status of the party
            createdAt:
              type: string
              format: date-time
              description: Timestamp when the party was created
            salutation:
              type: string
              nullable: true
              description: Formal greeting prefix (e.g., Mr, Mrs, Ms, Dr)
            title:
              type: string
              nullable: true
              description: Honorary, professional, or academic title
            firstName:
              type: string
              nullable: true
              description: The individual's first name or given name
            lastName:
              type: string
              nullable: true
              description: The individual's last name or family name
            middleNames:
              type: string
              nullable: true
              description: Any middle names or initials
            dateOfBirth:
              type: string
              format: date
              nullable: true
              description: The individual's date of birth in ISO format (YYYY-MM-DD)
            phoneNumber:
              type: string
              nullable: true
              description: Contact phone number
            email:
              type: string
              nullable: true
              description: Email address
            personalId:
              type: string
              nullable: true
              description: Personal identification number or code
            preferredLanguage:
              type: string
              nullable: true
              description: The individual's preferred language for communication
            registrationAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Official registered address
            postalAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Address for postal mail if different from registration address
            taxIdentifications:
              type: array
              nullable: true
              description: List of tax identification information
              items:
                $ref: '#/components/schemas/TaxIdentification'
            documents:
              type: array
              nullable: true
              description: List of identification documents
              items:
                $ref: '#/components/schemas/Document'
            additionalDetails:
              type: object
              additionalProperties: true
              nullable: true
              description: Additional custom details stored as key-value pairs (maps to Java Map<String, Object>)
            leadId:
              type: string
              nullable: true
              description: The identifier of the lead that originated this party creation
            skipCustomerCreation:
              type: boolean
              nullable: true
              description: Describes if the party was created without creating a customer record. By default, a customer is created for the party.

    IndividualPartyCreationFailed:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when an attempt to create an individual party has failed
          required:
            - failure
          properties:
            failure:
              $ref: '#/components/schemas/Failure'
              description: Details about the failure

    IndividualLeadCreated:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when a new individual lead has been created
          required:
            - qualifiedOriginPartyId
            - leadId
            - status
            - createdAt
          properties:
            qualifiedOriginPartyId:
              type: string
              format: uri
              description: The qualified origin system identifier assigned to the newly created party
            leadId:
              type: string
              description: The unique identifier assigned to the newly created lead
            status:
              $ref: '#/components/schemas/Status'
              description: The initial activity status of the lead
            createdAt:
              type: string
              format: date-time
              description: Timestamp when the lead was created
            salutation:
              type: string
              nullable: true
              description: Formal greeting prefix (e.g., Mr, Mrs, Ms, Dr)
            title:
              type: string
              nullable: true
              description: Honorary, professional, or academic title
            firstName:
              type: string
              nullable: true
              description: The individual's first name or given name
            lastName:
              type: string
              nullable: true
              description: The individual's last name or family name
            middleNames:
              type: string
              nullable: true
              description: Any middle names or initials
            dateOfBirth:
              type: string
              format: date
              nullable: true
              description: The individual's date of birth in ISO format (YYYY-MM-DD)
            phoneNumber:
              type: string
              nullable: true
              description: Contact phone number
            email:
              type: string
              nullable: true
              description: Email address
            personalId:
              type: string
              nullable: true
              description: Personal identification number or code
            preferredLanguage:
              type: string
              nullable: true
              description: The individual's preferred language for communication
            registrationAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Official registered address
            postalAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Address for postal mail if different from registration address
            taxIdentifications:
              type: array
              nullable: true
              description: List of tax identification information
              items:
                $ref: '#/components/schemas/TaxIdentification'
            documents:
              type: array
              nullable: true
              description: List of identification documents
              items:
                $ref: '#/components/schemas/Document'
            additionalDetails:
              type: object
              additionalProperties: true
              nullable: true
              description: Additional custom details stored as key-value pairs (maps to Java Map<String, Object>)

    IndividualLeadCreationFailed:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when an attempt to create an individual lead has failed
          required:
            - failure
          properties:
            failure:
              $ref: '#/components/schemas/Failure'
              description: Details about the failure
            qualifiedOriginPartyId:
              type: string
              format: uri
              nullable: true
              description: Populated when a duplicate party is detected; contains the qualified origin system identifier of the matching party

    OrganisationPartyCreated:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when a new organisation party has been created
          required:
            - qualifiedOriginPartyId
            - createdAt
          properties:
            qualifiedOriginPartyId:
              type: string
              format: uri
              description: The qualified origin system identifier assigned to the newly created organization
            createdAt:
              type: string
              format: date-time
              description: Timestamp when the organization was created
            country:
              type: string
              nullable: true
              description: The country where the organization is registered
            legalName:
              type: string
              nullable: true
              description: The official registered legal name of the organization
            registrationNumber:
              type: string
              nullable: true
              description: Official company registration number
            dateOfIncorporation:
              type: string
              format: date
              nullable: true
              description: Date when the organization was officially incorporated or established
            legalType:
              type: string
              nullable: true
              description: Legal type or structure of the organization (e.g., LLC, Ltd, Inc)
            tradingName:
              type: string
              nullable: true
              description: The name under which the organization conducts business, if different from legal name
            registrationAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Official registered address of the organization
            operatingAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Primary business or operational address if different from registration address
            postalAddress:
              $ref: '#/components/schemas/Address'
              nullable: true
              description: Address for postal mail if different from other addresses
            categories:
              type: array
              nullable: true
              description: Business categories or industry classifications
              items:
                type: string
            website:
              type: string
              nullable: true
              description: Official website URL
            description:
              type: string
              nullable: true
              description: Brief description of the organization's activities
            vatNumber:
              type: string
              nullable: true
              description: Value Added Tax registration number
            members:
              type: array
              nullable: true
              description: List of parties that are members of this organization
              items:
                $ref: '#/components/schemas/OrganisationMember'
    
    OrganisationPartyCreationFailed:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when an attempt to create an organisation party has failed
          required:
            - failure
          properties:
            failure:
              $ref: '#/components/schemas/Failure'
              description: Details about the failure

    IndividualPersonalDetailsUpdated:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when an individual's personal details are updated
          required:
            - id
            - qualifiedOriginPartyId
            - phoneNumber
            - firstName
            - lastName
          properties:
            qualifiedOriginPartyId:
              type: string
              format: uri
              description: The qualified origin system identifier of the individual party whose details were updated
            phoneNumber:
              type: string
              description: Updated contact phone number
            email:
              type: string
              nullable: true
              description: Updated email address (if provided)
            firstName:
              type: string
              description: Updated first name
            lastName:
              type: string
              description: Updated last name

    OrganisationMemberAssigned:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when a party has been successfully assigned as a member of an organisation
          required:
            - id
            - organisationQualifiedOriginPartyId
            - memberQualifiedOriginPartyId
          properties:
            id:
              type: string
              description: Unique identifier for the event
            organisationQualifiedOriginPartyId:
              type: string
              format: uri
              description: The qualified origin system identifier of the organisation to which the member was assigned
            memberQualifiedOriginPartyId:
              type: string
              format: uri
              description: The qualified origin system identifier of the party that was assigned as a member

    OrganisationMemberAssignmentFailed:
      allOf:
        - $ref: '#/components/schemas/Event'
        - type: object
          description: Event published when an attempt to assign a member to an organisation has failed
          required:
            - id
            - failure
          properties:
            id:
              type: string
              description: Unique identifier for the event
            organisationQualifiedOriginPartyId:
              type: string
              format: uri
              nullable: true
              description: The qualified origin system identifier of the organisation (if available)
            memberQualifiedOriginPartyId:
              type: string
              format: uri
              nullable: true
              description: The qualified origin system identifier of the party that failed to be assigned (if available)
            failure:
              $ref: '#/components/schemas/Failure'
              description: Details about the failure